" Vim syntax file
" Language:     ISPL (Interpreted Systems Programming Language)
" Maintainer:   Andrew Jones <andrewj@doc.ic.ac.uk>
" Last change:  12 September, 2009
"
" put this into to your ~/.vimrc
"
"    augroup syntax
"    au! BufNewFile,BufReadPost *.ispl
"    au  BufNewFile,BufReadPost *.ispl so ~/.vim/syntax/ispl.vim
"    augroup END
"
" ... and save this file as ~/.vim/syntax/ispl.vim
" ------------------------------------------------
"  This file is based on Armin Biere's SMV syntax file
"  http://www.cs.cmu.edu/~modelcheck/smv/vimrc
" ------------------------------------------------


" Remove any old syntax stuff hanging around
syn clear

" Keywords
syn keyword isplKeyword Obsvars
syn keyword isplKeyword Lobsvars
syn keyword isplKeyword Vars
syn keyword isplKeyword RedStates
syn keyword isplKeyword Actions
syn keyword isplKeyword Protocol
syn keyword isplKeyword Evolution
syn keyword isplKeyword Agent
syn keyword isplKeyword Environment
syn keyword isplKeyword Evaluation
syn keyword isplKeyword InitStates
syn keyword isplKeyword Formulae
syn keyword isplKeyword Fairness
syn keyword isplKeyword Groups

" Action - separate rule
syn keyword isplAction Action

" Operators
syn keyword isplOperator EX
syn keyword isplOperator AX
syn keyword isplOperator EF
syn keyword isplOperator AF
syn keyword isplOperator EG
syn keyword isplOperator AG
syn keyword isplOperator E
syn keyword isplOperator A
syn keyword isplOperator U
syn keyword isplOperator K

" Special end keyword
syn keyword isplPreProc end

" Operators
syn match isplOperator         "[=]"
syn match isplOperator         "[->]"
syn match isplOperator         "[!]"
syn match isplOperator         "[>]"
syn match isplOperator         "[<]"
syn match isplOperator         "[>=]"
syn match isplOperator         "[<=]"
syn match isplOperator         "[:]"
syn match isplOperator         "[..]"

" Booleans
syn keyword isplBool         true
syn keyword isplBool         false
syn keyword isplBool         if
syn keyword isplBool         and
syn keyword isplBool         or
syn keyword isplBool         !
syn keyword isplBool         boolean

" Constants
syn match   isplNumber         "-\=\<[0-9]\+"

"Comment
syn match   isplComment        "--.*"

" Catch mismatched parentheses
syn region isplGeneric         transparent start="{" end="}" contains=ALLBUT,isplBracketError
syn region isplParen           transparent start="(" end=")" contains=ALLBUT,isplParenError
syn match isplParenError       ")"
syn match isplBracketError     "}"

" Agent blocks wrapped in {}
syn region isplDefinition start="{" end="}"

syn sync lines=10

" These definitions aren't the obvious ones
" I've picked ones which format the ISPL nicest
if !exists("did_ispl_syntax_inits")
  let did_ispl_syntax_inits = 1
  hi link isplKeyword           Statement
  hi link isplConstant          Number
  hi link isplNumber            Number
  hi link isplOperator          PreProc
  hi link isplComment           Comment
  hi link isplBool              Type
  hi link isplParenError        Error
  hi link isplBracketError      Error
  hi link isplDefinition         String
  hi link isplAction            String
  hi link isplStatement         Statement
  hi link isplPreProc            PreProc
endif

let b:current_syntax = "ispl"

